package com.onetech.adrewards.free.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.fedorvlasov.lazylist.ImageLoaderWithSize;
import com.onetech.adrewards.free.OneTech_ApplicationContext;
import com.onetech.adrewards.free.R;
import com.onetech.adrewards.free.activities.BaseNewActivity;
import com.onetech.adrewards.free.objects.SlideDTO;
import com.onetech.adrewards.free.utils.AdrewadsUtils;

public class ImageSlideFragment extends Fragment implements OnClickListener{
	public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
	private SlideDTO mSlideData;
	private ImageView mImageBanner=null;
	private View mView=null;
	public static final ImageSlideFragment newInstance(String message,
			SlideDTO _mSlideData) {
		ImageSlideFragment f = new ImageSlideFragment();
		f.mSlideData=_mSlideData;
		return f;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView=inflater.inflate(R.layout.slide_banner_home_layout, container, false);		
		mImageBanner=(ImageView)mView.findViewById(R.id.slideImage);
		mImageBanner.setOnClickListener(this);
			//ImageLoader.getInstance(OneTech_ApplicationContext.getContext()).DisplayImage(mSlideData.img, mImageBanner);
		
		return mView;
	}
	@Override
	public void onResume() {
		super.onResume();
		try {
			ImageLoaderWithSize.getInstance(OneTech_ApplicationContext.getContext()).DisplayImage(mSlideData.img, mImageBanner);
		} catch (Exception e) {
		}
	}
	@Override
	public void onClick(View v) {
		try {			
				if(mSlideData.type.trim().equals("2")){
//					Intent inviteIntent=new Intent(getActivity(), InviteFriendsActivity.class);
//					startActivity(inviteIntent);
					((BaseNewActivity)getActivity()).onNavigationDrawerItemSelected(5);
				}else{
					AdrewadsUtils.go2Web(OneTech_ApplicationContext.getContext(), mSlideData.url);
				}
								
			//AdrewadsUtils.go2Web(OneTech_ApplicationContext.getContext(), mSlideData.url);
		} catch (Exception e) {
			return;
		}
	}

}
